package com.cj.core.response;

import com.alibaba.fastjson2.JSON;

/**
* @Description: 自定义的内部异常处理类、RuntimeException会进行事务回滚
* @Author: 陈军
* @Tel: 13984919416
* @Date: 2022/5/13
*/
public class CJExceptionHandle extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public CJExceptionHandle(REnum rEnum, String msg) {
        this(setMessageAndGet(rEnum, msg));  // ✅ this() 是第一条语句
    }

    public CJExceptionHandle(REnum rEnum) {
        super(JSON.toJSONString(rEnum));
    }

    private static REnum setMessageAndGet(REnum rEnum, String msg) {
        rEnum.setMsg(msg);
        return rEnum;
    }
}
